package com.qf.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.qf.exeptions.ResultCode;
import com.sun.corba.se.spi.ior.ObjectKey;

/*
杨威
2021/12/31
12:55
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)//这个注解直解析不为空的数据
public class R {
    private int resultCode;//状态码
    private String message;//提示信息
    private Object data;//携带的数据

    public static R setOk(){
        return setOk(null);
    }
    public static R setOk(Object obj){
       return setError(ResultCode.SUCCESS,"成功", obj);
    }

    public static R setError(int code,String message){
        return setError(code,message,null);
    }
    public static R setError(int code,String message,Object obj){
        R r=new R();
        r.setResultCode(code);
        r.setMessage(message);
        r.setData(obj);
        return r;
    }

    public int getResultCode() {
        return resultCode;
    }

    public void setResultCode(int resultCode) {
        this.resultCode = resultCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
